package com.edu.admin.utils;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

/**
 * 
 * @author Wangjiong
 *
 */
public class JsonUtils {

	public static String parseObjToJson(Object object) {
		String string = null;
		try {
			string = JSONObject.toJSONString(object);
		} catch (Exception e) {
			System.out.println(e.getMessage());
		}
		return string;
	}

	public static <T> T parseJsonToObj(String json, Class<T> c) {
		try {
			JSONObject jsonObject = JSON.parseObject(json);
			return JSON.toJavaObject(jsonObject, c);
		} catch (Exception e) {
			System.out.println(e.getMessage());
		}
		return null;
	}

}
